package kz.kstu.scantest.desktop.run;

import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;
import kz.kstu.scantest.desktop.ui.frame.ApplicationFrame;
import kz.kstu.scantest.desktop.util.GUIUtils;
import kz.kstu.scantest.desktop.util.health.HealthManager;
import kz.kstu.scantest.desktop.util.shell.StartScreen;
import org.apache.log4j.Logger;

import javax.swing.*;

/**
 * @author Filipp_Stankevich
 *         created: 7/25/11 5:58 PM
 */
public class Client {

    private final static Logger LOGGER = Logger.getLogger(Client.class);

    public static void main(String[] args) {

        LookAndFeel lookAndFeel = new WindowsLookAndFeel();
        try {
            UIManager.setLookAndFeel(lookAndFeel);
        } catch (UnsupportedLookAndFeelException e) {
            LOGGER.error(e.getMessage(), e);
        }

        StartScreen.getInstance().show();

        Runnable runnable = new Runnable() {
            /**
             * Start all in EDT.
             */
            public void run() {
                ApplicationFrame applicationFrame = new ApplicationFrame();
                applicationFrame.initStaticComponents();
                applicationFrame.initData();
                GUIUtils.centerAndShow(applicationFrame);
                StartScreen.getInstance().hide();
            }
        };
        HealthManager.getInstance().logAnyError();
        SwingUtilities.invokeLater(runnable);
    }
}

